man.java
Language: Java
Last Modified: 2020-06-27 1:58:33 PM UTC
File Size: 1296 bytes
Last Modified: 2020-06-27 1:58:33 PM UTC
File Size: 1296 bytes
http://www.penguinstew.ca/example/hangman/man.java
public class man {
private int value;
public man(){
this.value = 0;
}
public void increase() {
this.value++;
}
public void reset(){
this.value = 0;
}
public void printMan(){
//Print the top section
System.out.println(" ------");
System.out.println(" | |");
System.out.print(" | ");
//Head section
if(this.value >= 1) {
System.out.println("O");
} else {
System.out.println();
}
System.out.print(" | ");
//Arms section
if(this.value >= 4) {
System.out.println("\\|/");
} else if (this.value >= 3) {
System.out.println("\\|");
} else if (this.value >= 2) {
System.out.println(" | ");
} else {
System.out.println();
}
System.out.print(" | ");
//Torso section
if (this.value >= 2) {
System.out.println("| ");
} else {
System.out.println();
}
System.out.print(" | ");
//Legs section
if(this.value >= 6) {
System.out.println("/ \\");
} else if (this.value >= 5) {
System.out.println("/");
} else {
System.out.println();
}
//Base section
System.out.println(" =====");
}
public boolean death(){
if(this.value >= 6) {
return true;
} else
return false;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74